package com.mine.async.utils;

public class DownloadCalcUtil {

    public static long getSelectedCount(long current, long pageSize, int recordSize) {
        if (current < 1)
            return 0;
        return recordSize + (current - 1) * pageSize;
    }

    public static int calcDownloadRatio(long current, long pageSize, int recordSize, long totalCount) {
        if (current <= 0 || pageSize <= 0 || totalCount <= 0)
            return 0;
        long selectedCount = getSelectedCount(current, pageSize, recordSize);
        if (selectedCount < 0)
            selectedCount = 0L;
        return (int) (selectedCount * 100 / totalCount);
    }
}
